package com.luhan.fmmall.service.impl;

import com.luhan.fmmall.dao.CategoryMapper;
import com.luhan.fmmall.entity.CategoryVO;
import com.luhan.fmmall.service.CategoryService;
import com.luhan.fmmall.vo.ResStatus;
import com.luhan.fmmall.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 查询分类列表，包含三个级别分类
     * @return
     */
    @Override
    public ResultVO listCategories() {
        List<CategoryVO> categories = categoryMapper.listCategories();
        return new ResultVO(ResStatus.OK,"success",categories);
    }

    /**
     * 查询所有一级分类，同时查询当前一级分类销量最高的6个商品
     * @return
     */
    @Override
    public ResultVO listFirstCategories() {
        List<CategoryVO> categoryVOS = categoryMapper.selectFirstCategiries();
        return new ResultVO(ResStatus.OK,"success",categoryVOS);
    }
}
